package com.yupi.yupicturebackend.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

@Getter
public enum SpaceTypeEnum {
    PRIVATE("私有空间",0),
    TEAM("团队空间",1);

    private final String  text;

    private final Integer value;
    SpaceTypeEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static SpaceTypeEnum getEnumByValue(Integer value) {
        if (ObjectUtil.isEmpty(value)) {
            return null;
        }
        for (SpaceTypeEnum spaceTypeEnum : SpaceTypeEnum.values()) {
            if(spaceTypeEnum.value.equals(value))
                return spaceTypeEnum;
        }
        return null;
    }
}
